package com.hww.doc.framework.config;

import org.apache.coyote.http11.Http11Nio2Protocol;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * hww-Tomcat相关配置 启用Nio2配置
 * 
 * @author yaxu.huang
 * @version 1.0
 * @date 2021-3-24
 * @since 1.0
 */
@SuppressWarnings("unused")
@Configuration
public class TomcatConfig {

	@Bean
	public ConfigurableServletWebServerFactory webServerFactoryNio() {
		TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
		factory.addConnectorCustomizers(connector -> {
			Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
			protocol.setDisableUploadTimeout(false);
		});
		return factory;
	}

	/*
	 * @Bean public ConfigurableServletWebServerFactory webServerFactoryNio2() {
	 * TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
	 * factory.addConnectorCustomizers(connector -> { Http11Nio2Protocol protocol =
	 * (Http11Nio2Protocol) connector.getProtocolHandler();
	 * protocol.setDisableUploadTimeout(false); }); return factory; }
	 */
}
